package com.lizemin.bank.service;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.lizemin.bank.entity.User;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lzm
 * @date 2025/4/10 21:01
 * @description
 */
@Service
public class UserService {

    private static final List<User> USERS;

    static {
        USERS = ListUtil.of(
                new User("邓布利多", "123"),
                new User("哈利波特", "456"),
                new User("赫敏", "789")
        );
    }

    public User findUserByUsername(String username) {
        return USERS.stream().filter(user ->
                        StrUtil.equals(username, user.getUsername()))
                .findFirst()
                .orElse(null);
    }

}
